<template>
	<view class="mui-content">
		<view class="top3">
			<view>
				<input type="password" placeholder="新密码" v-model="newPassword" class="suo">
			</view>
			<view>
				<input type="password" placeholder="确认密码" v-model="newPasswordTwo" class="suo">
			</view>
		</view>
		<button class="top" @click="submit()">确认</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone: '', 			//手机号
				newPassword: '',	//新密码
				newPasswordTwo: '', //确认密码
			}
		},
		onLoad(opt) {
			this.phone = opt.phone
		},
		methods: {
			onXin(e){
				this.newPassword = e.target.value;
			},
			onXinTwo(e){
				this.newPasswordTwo = e.target.value;
			},
			submit(){
				console.log("来确认修改密码了："+this.newPassword+" "+this.newPasswordTwo)
				if(this.isNull(this.newPassword) || this.isNull(this.newPasswordTwo)){
					this.$u.toast("密码不能为空！");
					return
				}
				if(this.newPassword.length < 6){
					this.$u.toast("密码长度不小于六位！");
					return
				}
				if(this.newPassword != this.newPasswordTwo){
					this.$u.toast("输入的两次密码不相同，请重新输入!");
					return
				}
				this.$http.get('/userinfo/restPasswordxcx',{
					password:this.newPassword,
					phone:this.phone
				}).then(res =>{
					if(res.data.code==200){
						this.$u.toast("修改密码成功");
						setTimeout(function(){
							uni.navigateTo({
								url:'../../pages/center/login'
							})
						},2000)
					}else{
						this.$u.toast("非法操作");
						return
					}
				})
			},
			isNull(str){
				return str==null || str=="" || str==undefined
			}
		}
	}
</script>

<style>
	.mui-content {
		padding-top: 8%;
	}
	.top3 {
		width: 90%;
		margin-left: 5%;
	}
	.top {
	    background: #EF6700;
	    width: 90%;
	    height: 45px;
	    /* color: lightgray; */
		color: white;
	    text-align: center !important;
	    margin-top: 8%;
	    margin-left: 5%;
	    font-size: 120%;
	    font-weight: bold;
	    line-height: 40px;
	}
	.suo{
		border: 0.5rpx #ecdede solid;
		background-color: white;
		height: 50px;
		padding-left: 40px;
		background-image: url(../../static/center/login_password.png);
		background-size: 20px;
		background-repeat: no-repeat;
		background-position-x: 10px;
		background-position-y: 15px;
	}
</style>
